/*
 *主页面
 */
'use strict';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Link,browserHistory } from 'react-router';
import Headers from '../../components/Header';
import Navigation from '../../components/Navigation';
import NavList from '../../components/Navigation/NavList.jsx';
import { Layout } from 'antd';
const { Header, Footer, Sider, Content } = Layout;
import '../../static/css/reset.css';
import '../../static/css/common.css';
import '../../static/css/icon.less';
import './App.css';
import Login from '../Login/index.jsx';
import { fetchPost, fetchPut, fetchGet, fetchDelete } from '../../static/js/httprequest';
import URL from '../../constants/HostConfig';
import $ from 'jquery';
let adminUser = false;

class App extends Component {
	constructor(props, context) {
    super(props);
		this.user = localStorage.getItem('user');
    this.state ={
		};
  }

	//调试信息
  componentWillMount(){
  	if(this.user){
  		adminUser = true;
  		this.setState({name:this.user});
    }else{
    	adminUser = false;
			browserHistory.push('/Login');
    }
  }

  render() {
  	return (
  		<div>
					<Layout style = {{ minHeight: document.body.clientHeight,minWidth: 980,dispaly:adminUser ? '':'none'}}>
						{/*头部*/}
		    		<Header className='header'>
							<Headers
								isOline = {false}
								userName = {this.state.name}
								menuList = {[{
									title: '退出登录',
									props: {
										onClick: () => {localStorage.clear('user');browserHistory.push('/Login');}
									}
								}]}
							/>
						</Header>
						<Layout>
							{/*导航条*/}
							<Sider className = 'navigation' style = {{dispaly:adminUser ? '':'none'}}>
								<Navigation
									navlist = {NavList}
									pathname = {this.props.location.pathname}
								/>
							</Sider>
							{/*右侧内容*/}
								<Content className = "main" style = {{padding:20}}>
									{this.props.children}
								</Content>
		    			</Layout>
					</Layout>
			</div>
		);
	}
}



function mapStateToProps(state) {
  return {
  }
}
export default connect(
  mapStateToProps,
  {
  }
)(App)
// export default App;
